class HappeningsController < ApplicationController

  # POST /happenings
  # POST /happenings.xml
  def create
    @happening = Happening.new(params[:happening])

    respond_to do |format|
      if @happening.save
        flash[:notice] = 'Happening was successfully created.'
        format.html { redirect_to happening_url(@happening) }
        format.xml  { head :created, :location => happening_url(@happening) }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @happening.errors.to_xml }
      end
    end
  end

  # PUT /happenings/1
  # PUT /happenings/1.xml
  def update
    @happening = Happening.find(params[:id])

    respond_to do |format|
      if @happening.update_attributes(params[:happening])
        flash[:notice] = 'Happening was successfully updated.'
        format.html { redirect_to happening_url(@happening) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @happening.errors.to_xml }
      end
    end
  end

  # DELETE /happenings/1
  # DELETE /happenings/1.xml
  def destroy
    @happening = Happening.find(params[:id])
    @happening.destroy

    respond_to do |format|
      format.html { redirect_to happenings_url }
      format.xml  { head :ok }
    end
  end
end
